package com.xw.pojo;


import lombok.Data;
import org.springframework.stereotype.Component;


@Component
public class Page {
    private Integer pageStartRow;
    private Integer pageIndex;
    private Integer pageSize;
    private Integer totalRow;
    private Integer totalPages;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    private  String name;
    public  String  id;


    public void setPage(Integer pageIndex) {
        this.pageIndex = pageIndex;
        this.pageSize = 6;
        this.setPageStartRow((pageIndex - 1) * 6);
    }
//
//    public Page(Integer pageIndex, Integer pageSize) {
//        this.pageIndex = pageIndex;
//        this.pageSize = pageSize;
//        this.setPageStartRow((pageIndex - 1) * pageIndex);
//    }

    public Integer getPageStartRow() {
        return pageStartRow;
    }

    public void setPageStartRow(Integer pageStartRow) {
        this.pageStartRow = pageStartRow;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(Integer totalRow) {
        this.totalRow = totalRow;
        this.setTotalPages(totalRow % pageSize == 0 ? totalRow / pageSize : totalRow / pageSize + 1);
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }


    @Override
    public String toString() {
        return "Page{" +
                "pageStartRow=" + pageStartRow +
                ", pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", totalRow=" + totalRow +
                ", totalPages=" + totalPages +
                '}';
    }
}

